<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en" dir="ltr">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="../codebase/default.css" type="text/css" media="screen" title="no title" charset="utf-8"><title>
    dhtmlxconnector:loading_editing_data    [DHX documentation]
  </title></head>

<body>
<div class="dokuwiki">
  
  <div class="stylehead">

    <div class="header">
    <a class="logo" href="http://dhtmlx.com" title="DHTMLX Home Page"></a>
    <span class="tittle-dhtmlx">DHTMLX Docs & Samples Explorer</span>

    <div class="search-field">
        <form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>    </div>
        <div class="buttons">
                <a class="doc"></a>
                <a title="DHTMLX Samples homepage" href="../samples.html" class="sample"/></a>
        </div>
     <!-- <div class="pagename">
        [[<a href="#"  title="Backlinks">dhtmlxconnector:loading_editing_data</a>]]
      </div>
      <div class="logo">
        <a href="/dhtmlx/docs/doku.php"  name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[H]">DHX documentation</a>      </div>

      <div class="clearer"></div>-->
        
    </div>

    
<!--   <div class="bar" id="bar__top">
      <div class="bar-left" id="bar__topleft">
        <form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>        <form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form>      </div>

      <div class="bar-right" id="bar__topright">
        <form class="button btn_recent" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="recent" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Recent changes" class="button" accesskey="r" title="Recent changes [R]" /></div></form>        <form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>&nbsp;
      </div>

      <div class="clearer"></div>
    </div> -->

<!--        <div class="breadcrumbs">
      <span class="bchead">Trace:</span> <span class="bcsep">&raquo;</span> <span class="curid"><a href="/dhtmlx/docs/doku.php?id=dhtmlxconnector:loading_editing_data"  class="breadcrumbs" title="dhtmlxconnector:loading_editing_data">loading_editing_data</a></span>    </div>
    -->

    
  </div>
  
  
  <div class="page">
    <!-- wikipage start -->
    <!-- TOC START -->
<div class="toc">
<div class="tocheader toctoggle" id="toc__header">Table of Contents</div>
<div id="toc__inside">

<ul class="toc">
<li class="clear">

<ul class="toc">
<li class="level2"><div class="li"><span class="li"><a href="#data_configuration" class="toc">Data configuration</a></span></div>
<ul class="toc">
<li class="level3"><div class="li"><span class="li"><a href="#single_table_operations" class="toc">Single table operations</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#join_tables_and_complex_queries_operations" class="toc">Join Tables and Complex Queries Operations</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#extra_data" class="toc">Extra data</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#tree_and_treegrid" class="toc">Tree and TreeGrid</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#aliases" class="toc">Aliases</a></span></div></li></ul>
</li></ul>
</li></ul>
</div>
</div>
<!-- TOC END -->

<p>
<div class='backlinks'><div class='backlink last_backlink'><img src="icons___file.gif"  class="media" alt="" /><a href="../index.html" class="wikilink1" title="start">Index</a></div><div class='arrow'></div><div class='backlink last_backlink'><img src="icons___connector.gif"  class="media" alt="" /><a href="index.html" class="wikilink1" title="dhtmlxconnector:toc">dhtmlxconnector</a></div><div class='arrow'></div><div class='backlink'><a href="dhtmlxconnector___toc_what_is_dhtmlxconnector.html" class="wikilink1" title="dhtmlxconnector:toc_what_is_dhtmlxconnector">Usage Guide</a></div></div>

</p>

<h2><a name="data_configuration" id="data_configuration">Data configuration</a></h2>
<div class="level2">

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="98-132" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Data configuration" /></div></form></div>
<h3><a name="single_table_operations" id="single_table_operations">Single table operations</a></h3>
<div class="level3">

<p>
Once you get connection object you are ready to decide what data should take part in load/update operations. Where all necessary data is placed in one database table you should use the render_table method:
</p>
<pre class="code php">    <span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;grid50&quot;</span><span class="sy0">,</span><span class="st0">&quot;item_id&quot;</span><span class="sy0">,</span><span class="st0">&quot;item_nm,item_cd&quot;</span><span class="br0">&#41;</span>;</pre>
<p>
The parameters of this method are:
</p>
<ul>
<li class="level1"><div class="li">    database table name</div>
</li>
<li class="level1"><div class="li">    name of identity field <sup><a href="#fn__1" name="fnt__1" id="fnt__1" class="fn_top">1)</a></sup></div>
</li>
<li class="level1"><div class="li">    list of fields which should be used as values of component item (cells of grid, item label in tree, text of option in combo)</div>
</li>
</ul>

<p>

This is all you need to make connector implement select, insert, update and delete operations.
</p>

<p>
If you want to render all fields from DB ( except of key field ), you can use simplified command
</p>
<pre class="code php">    <span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;grid50&quot;</span><span class="br0">&#41;</span>;</pre>
</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="133-946" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Single table operations" /></div></form></div>
<h3><a name="join_tables_and_complex_queries_operations" id="join_tables_and_complex_queries_operations">Join Tables and Complex Queries Operations</a></h3>
<div class="level3">

<p>

You are allowed to use any <acronym title="Structured Query Language">SQL</acronym> statements to populate any dhtmlx component through dhtmlxConnector. This is possible with the render_sql method:
</p>
<pre class="code php">        <span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_sql</span><span class="br0">&#40;</span><span class="st0">&quot;SELECT * from tableA INNER JOIN tableB  ON tableA.id=tableB.id&quot;</span><span class="sy0">,</span> <span class="st0">&quot;&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price&quot;</span><span class="br0">&#41;</span>;</pre>
<p>

The parameters of the render_sql method are the following:
</p>
<ul>
<li class="level1"><div class="li">      sql statement</div>
</li>
<li class="level1"><div class="li">      field to use as identifier <sup><a href="#fn__2" name="fnt__2" id="fnt__2" class="fn_top">2)</a></sup></div>
</li>
<li class="level1"><div class="li">      list of fields which should be used as values of component item (cells for grid, item label for tree, text of option for combo)</div>
</li>
<li class="level1"><div class="li">      list of extra fields, they will not be sent to client side but can be used as attributes or flags</div>
</li>
<li class="level1"><div class="li">      parent ID field name for hierarchical structures (required for tree and treegrid) *</div>
</li>
</ul>

<p>
  
In case your <acronym title="Structured Query Language">SQL</acronym> query was against single table, it is quite probable that insert/update/delete operations do not require any additional code. dhtmlxConnector will parse your <acronym title="Structured Query Language">SQL</acronym> and generate insert/update/delete statements based on used table and fields names.
</p>

<p>
If your <acronym title="Structured Query Language">SQL</acronym> statement contains more than one table, connector will not be able to generate insert/update/delete operations correctly, so you will need do one from next
</p>
<ul>
<li class="level1"><div class="li"> define sql for each operation manually</div>
</li>
<li class="level1"><div class="li"> use server side events to define your own processing logic</div>
</li>
<li class="level1"><div class="li"> define different configs for select and update operations</div>
</li>
</ul>

<p>

The 3rd approach shown in below sample

</p>
<pre class="code php">    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">is_select_mode</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="co1">//code for loading data</span>
        <span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_sql</span><span class="br0">&#40;</span><span class="st0">&quot;Select * from tableA, tableB  where  tableA.id=tableB.id&quot;</span><span class="sy0">,</span> <span class="st0">&quot;a.id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price,other&quot;</span><span class="br0">&#41;</span>;
    <span class="kw1">else</span> <span class="co1">//code for other operations - i.e. update/insert/delete</span>
        <span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;tableA&quot;</span><span class="sy0">,</span><span class="st0">&quot;id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price&quot;</span><span class="br0">&#41;</span>;</pre>
<p>

With such init code grid will be loaded with three columns of data from 2 tables, but during saving only data from first table will be saved. 
</p>

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="947-2842" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Join Tables and Complex Queries Operations" /></div></form></div>
<h3><a name="extra_data" id="extra_data">Extra data</a></h3>
<div class="level3">

<p>
Last parameter of render_sql and render_table allows to define list of fields which will be used for rendering in grid and in update|insert operations, but command can be extended to define additional fields, which will be extracted from DB and can be mapped to different properties of records ( userdata, row styles, images, etc. ). 
</p>
<pre class="code php"><span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;tableA&quot;</span><span class="sy0">,</span><span class="st0">&quot;id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price&quot;</span><span class="sy0">,</span><span class="st0">&quot;extra1,extra2&quot;</span><span class="br0">&#41;</span>;
<span class="co1">// or</span>
<span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_sql</span><span class="br0">&#40;</span><span class="st0">&quot;Select * from tableA, tableB  where  tableA.id=tableB.id&quot;</span><span class="sy0">,</span> <span class="st0">&quot;table_a_id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price,other&quot;</span><span class="sy0">,</span><span class="st0">&quot;extra1,extra2&quot;</span><span class="br0">&#41;</span>;</pre>
<p>

extra1 and extra2 fields will be available in all server side event of grid, but will not be sent to server side, and will not be included in update|insert operations. 
</p>

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="2843-3588" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Extra data" /></div></form></div>
<h3><a name="tree_and_treegrid" id="tree_and_treegrid">Tree and TreeGrid</a></h3>
<div class="level3">

<p>

In case of Tree and TreeGrid , both render_sql and render_table accept one more parameter - relation ID. For default treegrid hierarchy - this is name of field , which will be used to link parent and child records. 

</p>
<pre class="code php"><span class="re0">$treeGridConn</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;tableA&quot;</span><span class="sy0">,</span><span class="st0">&quot;id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price&quot;</span><span class="sy0">,</span><span class="st0">&quot;&quot;</span><span class="sy0">,</span><span class="st0">&quot;parent_id&quot;</span><span class="br0">&#41;</span>;
<span class="co1">// or</span>
<span class="re0">$treeGridConn</span><span class="sy0">-&gt;</span><span class="me1">render_sql</span><span class="br0">&#40;</span><span class="st0">&quot;Select * from tableA, tableB  where  tableA.id=tableB.id&quot;</span><span class="sy0">,</span> <span class="st0">&quot;a.id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price,other&quot;</span><span class="sy0">,</span><span class="st0">&quot;&quot;</span><span class="sy0">,</span><span class="st0">&quot;parent_id&quot;</span><span class="br0">&#41;</span>;</pre>
</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="3589-4061" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Tree and TreeGrid" /></div></form></div>
<h3><a name="aliases" id="aliases">Aliases</a></h3>
<div class="level3">

<p>
You can use aliases for DB field names to made later usage of extracted data more usable ( will have sense only if your are using server side events )

</p>
<pre class="code php"><span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;tableA&quot;</span><span class="sy0">,</span><span class="st0">&quot;id&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price(product_price)&quot;</span><span class="br0">&#41;</span>;
<span class="co1">// or</span>
<span class="re0">$grid</span><span class="sy0">-&gt;</span><span class="me1">render_sql</span><span class="br0">&#40;</span><span class="st0">&quot;Select *,tableA.id as aid from tableA, tableB  where  tableA.id=tableB.id&quot;</span><span class="sy0">,</span> <span class="st0">&quot;tableA.id(aid)&quot;</span><span class="sy0">,</span><span class="st0">&quot;name,price(product_price),other&quot;</span><span class="br0">&#41;</span>;</pre>
</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="4062-" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit" class="button" title="Aliases" /></div></form></div><div class="footnotes">
<div class="fn"><sup><a href="#fnt__1" id="fn__1" name="fn__1" class="fn_bot">1)</a></sup> 
, <sup><a href="#fnt__2" id="fn__2" name="fn__2" class="fn_bot">2)</a></sup> 
optional</div>
</div>

    <!-- wikipage stop -->
  </div>

  <div class="clearer">&nbsp;</div>

  
  <div class="stylefoot">

    <div class="meta">
      <div class="user">
              </div>
     <!-- <div class="doc">
        dhtmlxconnector/loading_editing_data.txt &middot; Last modified: 2010/07/13 17:27 (external edit)      </div>
    </div>-->

   
    <!--<div class="bar" id="bar__bottom">-->
      <!--<div class="bar-left" id="bar__bottomleft">-->
        <!--<form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>-->
        <!--<form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form>-->
      <!--</div>-->
      <!--<div class="bar-right" id="bar__bottomright">-->
        <!---->
        <!---->
        <!---->
        <!---->
        <!---->
        <!--<form class="button btn_index" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="index" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Index" class="button" accesskey="x" title="Index [X]" /></div></form>-->
        <!--<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="Back to top" onclick="window.scrollTo(0, 0)" title="Back to top" /></a>&nbsp;-->
      <!--</div>-->
      <!--<div class="clearer"></div>-->
    <!--</div>-->

  </div>

  

</div>

<div class="footerinc">


</div>

<div class="no"><img src="/dhtmlx/docs/lib/exe/indexer.php?id=dhtmlxconnector%3Aloading_editing_data&amp;1279804813" width="1" height="1" alt=""  /></div>
     <div class="footer">
        <div class="footer-logo"></div>
        <div class="copyright">Copyright © 1998-2009 DHTMLX LTD.<br />All rights reserved.</div>
        <form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:loading_editing_data" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>    	    </div>
</body>
</html>
